package com.tools.scanner.ui.qrcode.creator.impl

import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.tools.scanner.R
import com.tools.scanner.databinding.FragmentGeoInputBinding
import com.tools.scanner.utils.ToastUtil

class CreateGeoFragment : BaseCreateFragment() {

    private lateinit var mBinding: FragmentGeoInputBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        mBinding = FragmentGeoInputBinding.inflate(inflater, container, false)
        return mBinding.root
    }

    override fun checkParams(): Boolean {
        if (TextUtils.isEmpty(mBinding.etLat.text.toString())) {
            ToastUtil.showToast(R.string.input_type_check_email)
            return false
        }

        if (TextUtils.isEmpty(mBinding.etLon.text.toString())) {
            ToastUtil.showToast(R.string.input_type_check_lon)
            return false
        }

        return true
    }

    override fun createQrCodeContent(): String {
        return "geo:${mBinding.etLat.text},${mBinding.etLon.text}"
    }
}